<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>商品管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <link rel="stylesheet" href="../css/admin.css" media="all">
    <link rel="stylesheet" href="../css/layui.css" media="all">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
    <style>
        #product{
  position: relative;
}
  .addForm{
     
    width: 100%;
    position: absolute;
    background-color: #fff;
    z-index: 10;
    top:0;
    left:0;
  }
    .layui-form-item{
      display: flex;
    }
  .layui-form-item .layui-form-label{
    display: inline-block;
    vertical-align: top;
     
   width: 20%;
  }
  .layui-form-item .layui-input-block{
    display: inline-block;
    vertical-align: top;
   
    margin-left:0;
     width: 74%;
  }
  .uploadBtn{
    border: 1px solid #000;
    position: relative;
    left: -120px;
    height: 100%;
    opacity: 0;
  }
</style>
</head>

<body>
    <div id="order">
      <br />
                <div class="layui-form-item " >

                    &nbsp; &nbsp; &nbsp; &nbsp;<button class="layui-btn layui-btn-sm add"  \>新增商品</button>
                </div>
                
            </div>
        <table class="layui-hide" id="test" lay-filter="test">
        </table>
        
        <script type="text/html" id="barDemo">
            <a class="layui-btn layui-btn-xs" lay-event="upGoods">上架</a>
            <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="downGoods">下架</a>
            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
        </script>
    </div>
    <form class="layui-form addForm"></form>
    <div class="adminform" style="background-color: #fff;padding:40px;">
        <br /> <br />
        <div class="layui-form form adminform">
            <div class="layui-form-item" style="display:none;">
                <label class="layui-form-label"></label>
                <div class="layui-input-block">
                    <input type="text" name="adminid" required lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">商品名称</label>
                <div class="layui-input-inline">
                    <input type="text" name="goodName" required lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">单价</label>
                <div class="layui-input-inline">
                    <input type="text" name="Price" required lay-verify="required" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">总代价格</label>
                <div class="layui-input-inline">
                    <input type="text" name="zd" required lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            
            </div>
              <div class="layui-form-item">
                <label class="layui-form-label">金钻价格</label>
                <div class="layui-input-inline">
                    <input type="text" name="jz" required lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            
            </div>
             <div class="layui-form-item">
                <label class="layui-form-label">商品分类</label>
                <div class="layui-input-inline">
                    <input type="text" name="cat" required lay-verify="required" autocomplete="off" class="layui-input">
                </div>
            
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">银钻价格</label>
                <div class="layui-input-inline">
                    <input type="text" name="yz" required lay-verify="required" autocomplete="off" class="layui-input">
                </div> 
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">团购价格</label>
                <div class="layui-input-inline">
                    <input type="text" name="tg" required lay-verify="required" autocomplete="off" class="layui-input">
                </div> 
            </div>
             <div class="layui-form-item">
                <label class="layui-form-label">描述</label>
                <div class="layui-input-inline">
                    <input type="text" name="miaoshu" required lay-verify="required" autocomplete="off" class="layui-input">
                </div> 
            </div>
             <div class="layui-form-item">
                <label class="layui-form-label">成分</label>
                <div class="layui-input-inline">
                    <input type="text" name="chengfen" required lay-verify="required" autocomplete="off" class="layui-input">
                </div> 
            </div>
             <div class="layui-form-item">
                <label class="layui-form-label">使用方法</label>
                <div class="layui-input-inline">
                    <input type="text" name="syff" required lay-verify="required" autocomplete="off" class="layui-input">
                </div> 
            </div>
             <div class="layui-form-item">
                <label class="layui-form-label">代理详情图片</label>
                <div class="layui-input-inline">
                    <input type="text" name="dailiimage" required lay-verify="required" autocomplete="off" class="layui-input">
                </div> 
            </div>
             <div class="layui-form-item">
                <label class="layui-form-label">商品的推荐奖励</label>
                <div class="layui-input-inline">
                    <input type="text" name="tuijian" required   autocomplete="off" class="layui-input">
                </div> 
            </div>
             <div class="layui-form-item">
                <label class="layui-form-label">上级服务人奖励</label>
                <div class="layui-input-inline">
                    <input type="text" name="superfuwu" required   autocomplete="off" class="layui-input">
                </div> 
            </div>
             <div class="layui-form-item">
                <label class="layui-form-label">申请代理的上级服务人奖励</label>
                <div class="layui-input-inline">
                    <input type="text" name="superioragentAward" required  autocomplete="off" class="layui-input">
                </div> 
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">商品图片</label>
                <div class="layui-input-inline">
                    <input type="file"   required     class="layui-input imgFile">
                </div> 
            </div>
            <div class="layui-form-item" style="display: none;">
                <label class="layui-form-label"></label>
                <div class="layui-input-inline">
                    <input type="text" name="img"       class="layui-input">
                </div> 
            </div>
            <div class="layui-form-item">
               <label class="layui-form-label"></label>
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-normal sub">提交</button>
                    <button class="layui-btn layui-btn-danger">取消</button>
                </div>
            </div>
        </div>
    </div>
</body>
<script type="text/javascript" src="../js/static.js"></script>
<script type="text/javascript" src="../js/global.js"></script>
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="../layui/layui.js"></script>
<script>
layui.config({
    base: '../' //静态资源所在路径
}).extend({
    index: 'lib/index' //主入口模块
}).use('index');
</script>
<script>
initTable("/m/good/getGoods");
$(".imgFile").change(function(event) {
    $("input[name='img']").val(returnImgStr($(this).split(",")[0]));
    console.log($("input[name='img']").val())
});
var key=[
"Price",
"img",
"goodName",
"adminid",
"zd",
"jz",
"cat",
"yz",
"tg",
"miaoshu",
"chengfen",
"syff",
"dailiimage",
"tuijian",
"superfuwu",
"fuwu",
"superioragentAward"
];

$(".adminform").hide();
$(".add").click(function() {
    /* Act on the event */
    $(".adminform").toggle();
    $("input[name=adminid]").val(getSession("if").id);
});
$(".sub").click(function() {
    var data = new FormData();
    for (let i in key) {
        data.append(key[i], $("input[name='" + key[i] + "']").val());
    }
    $.ajax({
        type: "POST",
        url: preUrl + "/a/sys/upGoods",
        processData: false,
        contentType: false,
        data: data,
        success: function(res) {
            if (res.suc) {
                layer.msg(res.msg)
                $("input[type='text']").val("");
              
            }
        },

    })
});
</script>

</html>